Skip to content

feat: add ability to override configs per-package - #1515

Open
shssoichiro wants to merge 1 commit into
Morganamilo:masterfrom
shssoichiro:per-package-overrides
Open

shssoichiro wants to merge 1 commit into
Morganamilo:masterfrom
shssoichiro:per-package-overrides

Conversation

@shssoichiro

Copy link
Copy Markdown

This feature enables users to specify per-package overrides in /etc/paru.conf. These overrides can be specified for individual packages or for a group of package.

A per-package override may be defined as follows:

[override.package.firefox]
MakepkgConf = /etc/makepkg-pgo.conf

This configuration would utilize the specified makepkg config file for only the firefox package.

A group override may be defined as follows:

[override.group.lto-builds]
Packages = mesa vulkan-radeon
MakepkgConf = /etc/makepkg-lto.conf
Overrides = { MAKEFLAGS = "-j$(nproc)", CFLAGS = "-O3 -march=native" }

This configuration allows specifying multiple packages that will use the same custom config. Both package and group overrides allow specifying either or both MakepkgConf, which uses a custom config file, and Overrides which directly applies the specified env vars to the build.

Closes #901

@ninetailedtori

Copy link
Copy Markdown
Contributor

Does this handle matching for upstream package groups as well? Not sure if we wanted to support that or not, because honestly this works fine, and I'm not too sure they're getting much use anyway (upstream's groups, I mean!)

@shssoichiro

shssoichiro commented Feb 23, 2026 •

Copy link
Copy Markdown
Author

It currently doesn't. It could be added by having paru resolve the group name in the paru.conf file to see if it matches the name of an upstream group, and expand that to the list of member packages in that group, though I also am not sure if that feature would be useful enough to implement. Or if it might cause confusion (someone wants to make a group named "plasma" not knowing it would apply to all packages in the "plasma" group upstream).

@ninetailedtori

Copy link
Copy Markdown
Contributor

Hmm, yeah I reckon you're right, keep it simple and have it user defined! Besides, for those who do want the packages in a group, they can find it rather easily on the arch repo sites :]

Comment thread src/config.rs Resolved
@shssoichiro
shssoichiro force-pushed the per-package-overrides branch from 57c66d4 to 997c217 Compare March 1, 2026 05:18
@ninetailedtori

ninetailedtori commented Mar 5, 2026 •

Copy link
Copy Markdown
Contributor

Do we support listing patch files, yet? That might be something we could consider. Having an automated patch function is quite easy, and allowing users to list patchfiles could help a lot when managing packages that might take a while before getting an upstream patch actually pushed. I'd recommend supporting patches JUST for patching PKGBUILD, so it's somewhat freedom for the user to patch the PKGBUILD to then load whatever patches they want for subprojects etc for each repo they want to do it for manually.

EDIT: I'm gonna push a PR to this PR, if that's ok? It'll include the ability to patch the PKGBUILD, using either remote or local patchfiles.

@ninetailedtori

Copy link
Copy Markdown
Contributor

shssoichiro#1 welcoming testing on this one! :3

@shssoichiro
shssoichiro force-pushed the per-package-overrides branch from cef8e8f to e4d1de9 Compare November 7, 2026 00:14
@shssoichiro

Copy link
Copy Markdown
Author

Been using it for a while as a daily driver including your patches. @ninetailedtori I'm going to squash your commit into mine to make rebasing easier, but I'll be sure to keep the attribution.

@shssoichiro
shssoichiro force-pushed the per-package-overrides branch from e4d1de9 to 09d8c5d Compare November 17, 2026 17:34
Co-authored-by: Toria <ninetailedtori@uwu.gal>
@shssoichiro
shssoichiro force-pushed the per-package-overrides branch from 09d8c5d to 9e74160 Compare November 18, 2026 23:21

@pfeifferj pfeifferj left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left some comments, otherwise lgtm

Comment thread src/install.rs
let saved_env = config.env.clone();

if let Some(ref ov) = pkg_override {
apply_patches(config, cwd, &ov.pkgbuild_patches).await?;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cwd is the directory where paru was invoked. if we use that instead of dir (the package checkout) this can fail to find the target or modify an unrelated checkout

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shoot, alright, that's a good shout!

Comment thread src/exec.rs
pkgdest: Option<&str>,
) -> Command {
let mut cmd = Command::new(&config.makepkg_bin);
cmd.envs(config.env.iter().map(|(key, value)| (key, value)));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this passes compiler overrides through the environment, but makepkg subsequently overwrites CFLAGS and similar settings when loading its configuration

we should pass these as makepkg KEY=value arguments

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wait, so it doesn't act similar to prepended-var setting? iirc it sets as an execve before calling, right? but I'm not too sure if it'll override like prepending in cli would, like CFLAGS="foo" makepkg vs this method of cmd.envs, as I do know of course that cli override > config > system but...curious to see.

Comment thread src/install.rs
if let Some(ref conf) = ov.makepkg_conf {
config.makepkg_conf = Some(conf.clone());
if config.chroot {
self.chroot.makepkg_conf = conf.clone();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this changes the chroot's makepkg_conf field after chroot setup, and Chroot::build doesn't end up reading that field. with the default empty ChrootPkgs, the host package-list query uses the override while the actual chroot build keeps its existing configuration. the selected configuration needs to reach the build chroot

Comment thread src/config.rs
tr!("override.group.{} must have MakepkgConf or Overrides", name)
);
for pkg in packages {
let entry = self.overrides.entry(pkg).or_default();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a later group can overwrite package-specific settings, contrary to the documented precedence. reversing the sections loses nonconflicting group settings through the package branch's insert. imo we should merge group settings first, then apply package-specific settings

@ninetailedtori ninetailedtori Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, I think that's what we should have, ya! I'll swap that around rq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Per Package configs

3 participants